//
//  HEMyOrderAddrssCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/5.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEMyOrderAddrssCell.h"

@interface HEMyOrderAddrssCell ()

@property (nonatomic, strong) UIImageView *logoImgView;

@property (nonatomic, strong) UILabel *nameLb;
@property (nonatomic, strong) UILabel *phoneLb;
@property (nonatomic, strong) UILabel *address;

@end

@implementation HEMyOrderAddrssCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
         self.selectionStyle = UITableViewCellSelectionStyleNone;
         [self initUI];
     }
     return self;;
 }

- (void)initUI {
    
    // 商品图片
    _logoImgView = [UIImageView new];
    _logoImgView.contentMode = UIViewContentModeScaleAspectFill;
    _logoImgView.image = IMAGE_NAMED(@"address_location");
    [self.contentView addSubview:_logoImgView];
    
    _nameLb = [UILabel new];
    _nameLb.text = @"-";
    _nameLb.font = DYFont(18);
    [self.contentView addSubview:_nameLb];
    
    _phoneLb = [UILabel new];
    _phoneLb.font = DYFont(16);
    _phoneLb.textColor = CNavSubTitleColor;
    _phoneLb.text = @"-";
     [self.contentView addSubview:_phoneLb];

    
    _address = [UILabel new];
    _address.numberOfLines = 0;
    _address.font = DYFont(14);
    _address.text = @"-";
    _address.textColor = CNavSubTitleColor;
     [self.contentView addSubview:_address];
    _address.preferredMaxLayoutWidth = KScreenWidth - 36 - 30 - 5 - 20;
    
    [_logoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.width.height.mas_offset(36);
        make.left.equalTo(self.contentView).mas_offset(10);
    }];
    
    [_nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(_logoImgView.mas_right).mas_offset(10);
    }];
    
    [_nameLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [_phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_nameLb);
        make.left.equalTo(_nameLb.mas_right).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-10);
     }];
    
    [_address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).mas_offset(10);
        make.left.equalTo(_nameLb.mas_left);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-10);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
 

}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    _nameLb.text = formModel.od_details.receiverName;
    _phoneLb.text = formModel.od_details.receiverPhone;
    _address.text = [NSString stringWithFormat:@"%@%@%@%@",formModel.od_details.receiverProvince, formModel.od_details.receiverCity, formModel.od_details.receiverRegion, formModel.od_details.receiverDetailAddress];
}
 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
